﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MarkInfo.aspx.cs" Inherits="Map_MarkInfo" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <style type="text/css">
        body {
            margin: 0;
            padding: 0;
        }
    </style>
    <link rel="stylesheet" id="skinCss" type="text/css" href="../css/default/easyui.css" />
    <link href="../css/bootstrap.css" rel="stylesheet" />
    <script src="../ScriptFile/jquery.js"></script>
    <script type="text/javascript" src="../ScriptFile/jquery.easyui.min.js"></script>
    <script src="../ScriptFile/bootstrap.js"></script>
    <script type="text/javascript">
        
        function getUrlParam(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
            var r = window.location.search.substr(1).match(reg);  //匹配目标参数
            if (r != null) return unescape(r[2]); return null; //返回参数值
        }

        function loadDropDownList($dropDown, typecode) {
            $.post("Ashx/BindDropDownHandler.ashx", { "typecode": typecode }, function (data, status) {
                var jsonObj = jQuery.parseJSON(data).DataDic;
                for (var i = 0; i < jsonObj.length; i++) {
                    var option = "<option value=\"" + jsonObj[i].Value + "\">" + jsonObj[i].Text + "</option>";
                    $dropDown.append(option);
                }
            });
        }

        //打开内嵌网页的通用方法1（window）
        function openDivDlg(strTitle, strUrl, divWidth, divHeight) {
            $('#dlgConfig').window({
                title: strTitle, width: divWidth, height: divHeight,
                collapsible: false, maximizable: false, inline: false,
                left: ($(window).width() - divWidth) / 2,
                top: ($(window).height() - divHeight) / 2,
                onClose: function () {

                }
            });
            $('#iframeConfig').attr("src", strUrl);
            $('#dlgConfig').window('open');
        }

        function getReturnValue(obj) {
            $("#txtXmName").val(obj.xmName);
            $("#hidxmiid").val(obj.iid);
            $('#dlgConfig').window('close');
        }
        
        var sonObj = new Object();

        $(function () {
            var drwingMode = getUrlParam('drwingMode');
            if (drwingMode == "polygon") {
                //loadDropDownList($("#ddlDataType"), "DATATYPE");
                //loadDropDownList($("#ddlPurpose"), "PURPOSE");
                $("#divDataType").css("display", "block");
                $("#divPurpose").css("display", "block");
            }

            $("#btnSave").on("click", function () {
                var name = $("#txtName").val();
                var xmiid = $("#hidxmiid").val();
                if (name == "") {
                    $.messager.alert("提示", "请填写名称", "info");
                    return false;
                }
                if (xmiid == "") {
                    $.messager.alert("提示", "请选择项目", "info");
                    return false;
                }
                var pointCollect = getUrlParam('point');
                var markAttr = getUrlParam('markAttr');
                var dataType = "";
                var purpose = "";
                if (drwingMode == "polygon") {
                    dataType = $("#ddlDataType").val();
                    purpose = $("#ddlPurpose").val();
                }
                var param = { "action": "Save", "name": "" + name + "", "xmiid": "" + xmiid + "", "markAttr": "" + markAttr + "", "dataType": "" + dataType + "", "purpose": "" + purpose + "", "point": "" + pointCollect + "" };
                $.post("Ashx/MapHandler.ashx", param, function (result) {
                    var jsonObj = $.parseJSON(result);
                    $.messager.alert("提示", "数据：" + jsonObj.ResultInfo, "info", function () {
                        sonObj.isClose = "";
                        sonObj.name = $("#txtName").val();
                        sonObj.xmiid = $("#hidxmiid").val();
                        sonObj.formId = jsonObj.FormId;
                        sonObj.bdcId = jsonObj.BdcId;
                        $(window.parent.closeDivDlg(sonObj));
                    });
                });
            });

            $("#btnCancel").on("click", function () {
                sonObj.isClose = "Close";
                $(window.parent.closeDivDlg(sonObj));
            });

            $("#txtXmName").on("click", function () {
                var dataType = $("#ddlDataType").val();
                var pageName = "";
                switch (dataType) {
                case "征地拆迁红线":
                    pageName = "ProjectInfoList.aspx";
                    break;
                case "不动产(土地)":
                    pageName = "EstateZDList.aspx";
                    break;
                case "不动产(房屋)":
                    pageName = "EstateHouseList.aspx";
                    break;
                }
                openDivDlg("选择项目", pageName, 800, 320);
            });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server" class="form-horizontal" role="form">
        <div id="dlgConfig" class="easyui-window" title="信息查看" closed="true" modal="true"
            minimizable="false" style="background: #fafafa; overflow: hidden;">
            <iframe id="iframeConfig" scrolling="no" frameborder="0" src="" style="width: 100%; height: 100%;"></iframe>
        </div>
        <div style="padding: 25px">
            <div class="form-group">
                <label for="txtName" class="col-sm-2 control-label">名称:</label>
                <div class="col-sm-6">
                    <input id="txtName" type="text" class="form-control" placeholder="名称" />
                </div>
            </div>
            <div id="divDataType" style="display: none" class="form-group">
                <label for="ddlDataType" class="col-sm-2 control-label">数据类型:</label>
                <div class="col-sm-6">
                    <select id="ddlDataType" runat="server" class="form-control">
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label for="txtXmName" class="col-sm-2 control-label">选择项目:</label>
                <div class="col-sm-6">
                    <input id="hidxmiid" type="hidden" />
                    <input id="txtXmName" type="text" class="form-control" readonly="readonly" />
                </div>
            </div>
            <div id="divPurpose" style="display: none" class="form-group">
                <label for="ddlPurpose" class="col-sm-2 control-label">用途:</label>
                <div class="col-sm-6">
                    <select id="ddlPurpose" runat="server" class="form-control">
                    </select>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-offset-4 col-sm-6" style="display: block">
                    <button id="btnSave" type="button" class="btn btn-primary">保存</button>
                    <button id="btnCancel" type="button" class="btn btn-default">取消</button>
                </div>
            </div>
        </div>
    </form>
</body>
</html>
